package com.ruoyi.stock2.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.stock2.mapper.SendEmailMapper;
import com.ruoyi.stock2.domain.SendEmail;
import com.ruoyi.stock2.service.ISendEmailService;
import com.ruoyi.common.core.text.Convert;

/**
 * 发送邮件Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-03-17
 */
@Service
public class SendEmailServiceImpl implements ISendEmailService 
{
    @Autowired(required = false)
    private SendEmailMapper sendEmailMapper;

    /**
     * 查询发送邮件
     * 
     * @param id 发送邮件ID
     * @return 发送邮件
     */
    @Override
    public SendEmail selectSendEmailById(Long id)
    {
        return sendEmailMapper.selectSendEmailById(id);
    }

    /**
     * 查询发送邮件列表
     * 
     * @param sendEmail 发送邮件
     * @return 发送邮件
     */
    @Override
    //@DataScope(deptAlias = "u", userAlias = "u")
    @DataScope(deptAlias = "u") //部门数据权限
    public List<SendEmail> selectSendEmailList(SendEmail sendEmail)
    {
        return sendEmailMapper.selectSendEmailList(sendEmail);
    }

    @Override
    public List<SendEmail> selectSendEmailListQuartz(SendEmail sendEmail)
    {
        return sendEmailMapper.selectSendEmailListQuartz(sendEmail);
    }

    /**
     * 新增发送邮件
     * 
     * @param sendEmail 发送邮件
     * @return 结果
     */
    @Override
    public int insertSendEmail(SendEmail sendEmail)
    {

        SysUser sysUser = ShiroUtils.getSysUser();
        sendEmail.setUserId(sysUser.getUserId());
        sendEmail.setDeptId(sysUser.getDeptId());
        return sendEmailMapper.insertSendEmail(sendEmail);
    }

    /**
     * 修改发送邮件
     * 
     * @param sendEmail 发送邮件
     * @return 结果
     */
    @Override
    public int updateSendEmail(SendEmail sendEmail)
    {
        return sendEmailMapper.updateSendEmail(sendEmail);
    }

    /**
     * 删除发送邮件对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteSendEmailByIds(String ids)
    {
        return sendEmailMapper.deleteSendEmailByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除发送邮件信息
     * 
     * @param id 发送邮件ID
     * @return 结果
     */
    @Override
    public int deleteSendEmailById(Long id)
    {
        return sendEmailMapper.deleteSendEmailById(id);
    }
}
